

#pragma once

#include "CEGUIOwner.h"
#include <CEGUI/CEGUI.h>
#include <OgreCEGUIRenderer.h>

#include <Ogre.h>

#include "IGameState.h"
#include "CameraController.h"
#include "DebuggeableState.h"

#include <NxOgre.h>

class MenuState : 
	public IGameState,
	private CEGUIOwner,
	private DebuggeableState,
	public NxOgre::ActorContactCallback
{
	Ogre::SceneManager * mSceneMgr;
	Ogre::Camera * mCamera;
	Ogre::Viewport * mViewport;

	Ogre::SceneNode * tiedNode;

	boost::scoped_ptr<CameraControl> mCameraControl;

	NxOgre::World * mWorld;
	NxOgre::Scene * mNxScene;

public:

	Ogre::SceneManager * GetOgreSceneManager() { return mSceneMgr; }
	Ogre::Camera * GetOgreCamera() { return mCamera; }
	Ogre::SceneNode * GetTieNode() { return tiedNode; }
	int GetNum() { return 5; }

	MenuState(BaseGameManager & gameManager);

	void createScene();

	virtual const char * GetStateName();

	//! Called when the menu state is entered.
	//!
	virtual void OnEnter();

	//! Creates the CEGUI menu.
	//!
	void createGUI();

	//! Called every frame.
	//!
	virtual bool OnFrameStarted(Ogre::FrameEvent const & evt);

	//! Called automatically when exiting the menu state.
	//! We destroy whatever has been created on OnEnter.
	virtual void OnExit();

	virtual void OnKeyPressed(OIS::KeyEvent const & e);

	virtual void OnKeyReleased(OIS::KeyEvent const & e);

	virtual bool OnMousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);

	virtual bool OnMouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);

	virtual bool OnMouseMoved(const OIS::MouseEvent &e);


	/* GUI events */


	//! Called when hitting the exit button.
	//!
	bool OnGUISalir(const CEGUI::EventArgs & e);

	//! Called when hitting the start button.
	//!
	bool OnGUIComenzar(const CEGUI::EventArgs & e);


	/* Physics events */

	void onBeginContact(NxOgre::Actor*, NxOgre::Actor*, NxContactPair&)
	{
		std::cout << "BeginContact" << std::endl;
	}

	void onEndContact(NxOgre::Actor*, NxOgre::Actor*, NxContactPair&)
	{		
		std::cout << "EndContact" << std::endl;
	}

	void onContact(NxOgre::Actor*, NxOgre::Actor*, NxContactPair&)
	{		
		std::cout << "OnContact" << std::endl;
	}
};